package reflection.cglibV2;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;

/**
 * @author ChangLiang
 * @date 2020/3/18
 */
public class BookDaoProxy implements MethodInterceptor {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        Object result;
        logger.info("transaction begin");
        result = proxy.invokeSuper(obj, args);
        logger.info("transaction end");
        return result;
    }

}
